package org.example.factory;

import lombok.Data;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * org.example.factory
 *
 * @author 莫磊
 * @description
 * @date 2025/7/20
 */
@Data
public class DateFactory implements FactoryBean<Date> {

    String date;

    String pattern;

    @Override
    public Date getObject() throws Exception {

        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date parse = sdf.parse(date);
        return parse;
    }

    @Override
    public Class<?> getObjectType() {
        return Date.class;
    }
}
